<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>
    My flask app got choked up : Forums : PythonAnywhere
</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="Forums : PythonAnywhere">
        <meta name="author" content="PythonAnywhere LLP">
        <meta name="google-site-verification" content="O4UxDrfcHjC44jybs2vajc1GgRkTKCTRgVzeV6I9V14" />

        <!-- Le styles -->
        <link href="/static/bootstrap/css/bootstrap.css" rel="stylesheet">
        <link href="/static/bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
        <link href="/static/anywhere/styles/bootstrap_base.css" rel="stylesheet">
        
    
    <link rel="stylesheet" href="/static/anywhere/styles/forums.css" type="text/css" media="screen" charset="utf-8" />

    <link rel="stylesheet" href="/static/pygments/style.css" type="text/css" media="screen" charset="utf-8" />

        <link rel="stylesheet" href="/static/jquery/jquery-ui-1.8.11.custom.css" type="text/css" media="screen" charset="utf-8" />
        
    
    <link rel="alternate" type="application/rss+xml" title="RSS" href="/forums/topic/831/rss" />

        <style type="text/css">
            body {
                height: auto;
            }
        </style>
        <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
        <!--[if lt IE 9]>
        <script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->

        <!-- Le fav and touch icons -->
        <link rel="apple-touch-icon" href="images/apple-touch-icon.png">
        <link rel="apple-touch-icon" sizes="72x72" href="images/apple-touch-icon-72x72.png">
        <link rel="apple-touch-icon" sizes="114x114" href="images/apple-touch-icon-114x114.png">
    </head>

     <body>
        <div class="navbar navbar-fixed-top">
            <div class="navbar-inner">
                <div id="id_internal_nav_bar_container" class="container">
                    <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    </a>
                    <a class="brand" href="/"><img id="id_logo" src="/static/anywhere/images/logo-234x35.png" height="35" title="PythonAnywhere logo" alt="PythonAnywhere logo" /></a>
                    <div class="nav-collapse">
                        <ul id="id_header_links" class="nav">
                            <li><a id="id_feedback_link" class='feedback_link' href="">Send feedback</a></li>
                            <li><a id="id_forums_link" href="/forums/">Forums</a></li>
                            <li><a href="/wiki/" id="id_help_link">Help</a></li>
                            <li><a href="http://blog.pythonanywhere.com/" id="id_blog_link">Blog</a></li>
                            
                            
                                <li><a style="font-weight: bold;" href="/pricing/" id="id_pricing_link">Pricing & signup</a></li>
                                <li><a href="/login/?next=/forums/topic/831/" id="id_login_link">Log in</a></li>
                            
                        </ul>
                    </div>
                </div>
            </div>
        </div>

        <div class="top-container" id="id_dummy"></div>

        

        
    
    <div class="container">
        <div class="row">
            <div class="span8 offset3">
                <h1>PythonAnywhere Forums</h1>
            </div>
        </div>



    <div class="row">
        <div class="span8 offset3">
            <p>
                <a href="/forums/start_topic/" id="id_start_new_topic">Start a new topic</a> |
                <a href="/forums/">Back to all topics</a> |
                <a href="/forums/topic/831/rss">This topic's RSS</a>
            </p>
        </div>
    </div>
    <div class="row">
        <div class="span8 offset3 topic">
            <h2>My flask app got choked up</h2>
        </div>
    </div>

    
        <div class="row">
            <div id="id_post_5888" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5888_content_text" class="span8">
                        <p>Well, earlier today, PythonAnywhere was unreachable for me and for the LSL scripts of mine that connect with my app.</p>
<p>What I'm doing is using Python Anywhere as a transient cache for URL data.  The LSL language (Linden Scripting Language) is for objects in Second Life, InWorldz, OpenSimulator, and similar systems.  Each script can obtain a URL, though the URL is ultimately transient (it will eventually expire, such as if a simulator or the script restarts).  So, I am using PythonAnywhere to act as an external cache for the URL's, so that my objects can communicate with each other.</p>
<p>Even after connectivity was re-established, however, it was nearly two hours before my LSL scripts were able to re-establish contact with my python application.  It wasn't until I manually shut down every single script and then restarted them one-by-one that normal functionality was restored.</p>
<p>From what I can tell, this may be a flaw in the Flask framework, which in my experience tends to choke whenever it gets hit by multiple requests simultaneously.</p>
<p>Does anyone know of a solution that I can use?  Is threading an option?</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5888_creator_details">
                            
                                
                            
                            zauberparacelsus
                            |
                            10
                            posts
                            |
                            
                        </span>
                        <span id="id_post_5888_created_date">
                            Aug. 13, 2013, 5:21 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/831/#id_post_5888">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_5889" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5889_content_text" class="span8">
                        <p>I see that the "choking on multiple requests" issue is resolved by deploying a flask app via WSGI or other such systems.  Problem though, is that I think Python Anywhere is already doing that by default, so either it's not solving the problem or the problem lies elsewhere.</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5889_creator_details">
                            
                                
                            
                            zauberparacelsus
                            |
                            10
                            posts
                            |
                            
                        </span>
                        <span id="id_post_5889_created_date">
                            Aug. 13, 2013, 5:31 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/831/#id_post_5889">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_5893" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5893_content_text" class="span8">
                        <p>Hi zauberparacelsus, </p>
<p>Free accounts have only one uWSGI worker. So yeah, if generating a response takes 4 seconds. Then you would only be able to deal with a request every 4 seconds. If you were getting more than 4 requests a second then they would start queuing up. Paid accounts have more uWSGI workers. Of course taking a long time per request is not optimal anyway. So it depends on how you have written your code. There is nothing stopping one worker from dealing with hunders to thousands of requests per second. But if you have the equivalent of a <code>time.sleep(10)</code> in your code then it will only handle exactly 6 requests a minute :-) </p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5893_creator_details">
                            
                                <img src="/static/anywhere/images/staff.png" alt="Staff" title="Staff"/>
                            
                            hansel
                            |
                            435
                            posts
                            |
                            
                                PythonAnywhere staff
                                |
                            
                        </span>
                        <span id="id_post_5893_created_date">
                            Aug. 13, 2013, 5:50 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/831/#id_post_5893">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_5896" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5896_content_text" class="span8">
                        <p>Well, the requests are usually instantaneous (or nearly so) for me.  The most load-intensive things they do is crunching SHA-256 hashes and making SQLite requests.</p>
<p>Now though, how many uWSGI workers does each account tier have?  I don't see that listed for the account features.</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5896_creator_details">
                            
                                
                            
                            zauberparacelsus
                            |
                            10
                            posts
                            |
                            
                        </span>
                        <span id="id_post_5896_created_date">
                            Aug. 13, 2013, 6:06 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/831/#id_post_5896">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_5902" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5902_content_text" class="span8">
                        <p>Hosting accounts have 3 workers, currently.  Are you sure you have the right diagnosis though?  If requests are usually instantaneous, but your LSL scripts took almost two hours to connect... How many are there?  Have you taken a look in your access log file, to see how many requests you're getting per hour?</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5902_creator_details">
                            
                                <img src="/static/anywhere/images/staff.png" alt="Staff" title="Staff"/>
                            
                            harry
                            |
                            376
                            posts
                            |
                            
                                PythonAnywhere staff
                                |
                            
                        </span>
                        <span id="id_post_5902_created_date">
                            Aug. 14, 2013, 2:14 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/831/#id_post_5902">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_5948" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5948_content_text" class="span8">
                        <p>Yeah, it was overloading.  The primary problem was that my timeouts were too short, so the requests just started piling up.  So, what I've done is increased the timeout lengths to make my LSL scripts less "impatient", and I've improved the code to minimize how much the scripts rely upon my app.  That, and I've improved their error handling.</p>
<p>It's been 3 days without any further problems, so I'll see how well these changes go.</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5948_creator_details">
                            
                                
                            
                            zauberparacelsus
                            |
                            10
                            posts
                            |
                            
                        </span>
                        <span id="id_post_5948_created_date">
                            Aug. 17, 2013, 3:08 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/831/#id_post_5948">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_5952" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5952_content_text" class="span8">
                        <p>Well, 11 of the LSL scripts suddenly hit the python app simultaneously, and it had no trouble at all handling them, so my previous conclusion of there being too many requests at once was in fact wrong.</p>
<p>So, the problem was most likely with requests taking too long to get through to the server.</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5952_creator_details">
                            
                                
                            
                            zauberparacelsus
                            |
                            10
                            posts
                            |
                            
                        </span>
                        <span id="id_post_5952_created_date">
                            Aug. 17, 2013, 4:17 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/831/#id_post_5952">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    

    




        <div id="id_footer" class="container">

            <footer id="id_copyright_div">
                <p>
                    Copyright &copy; 2013 PythonAnywhere LLP
                    &mdash;
                    <a href="/terms/">Terms</a>
                    &mdash;
                    <a href="/privacy/">Privacy</a><br/>
                    "Python" is a registered trademark of the Python Software Foundation.
                </p>
            </footer>

        </div>

        
        

        <div id="id_feedback_dialog" title="Help us improve" style="display:none">
    <div id="id_feedback_dialog_blurb_big" class="dialog_blurb_big">
        It's always a pleasure to hear from you!
    </div>
    <div id="id_feedback_dialog_blurb_small">
        Ask us a question, or tell us what you love or hate about PythonAnywhere.<br/>
        We'll get back to you over email ASAP.
    </div>
    <textarea id="id_feedback_dialog_text" rows="6"></textarea>
    <input id="id_feedback_dialog_email_address" type="text" class="default_prompt"/>
    <div id="id_feedback_dialog_error" class="pa_hidden">
        Sorry, there was an error connecting to the server. <br/>Please try again in a few moments...
    </div>
    <div class="dialog_buttons">
        <img id="id_feedback_dialog_spinner" src="/static/anywhere/images/spinner-small.gif" />
        <button class="btn btn-primary" id="id_feedback_dialog_ok_button">OK</button>
        <button class="btn" id="id_feedback_dialog_cancel_button">Cancel</button>
    </div>
</div>


        <!-- Le javascript
        ================================================== -->
        <!-- Placed at the end of the document so the pages load faster -->
        <script type="text/javascript" src="/static/jquery/jquery-1.7.1.min.js"></script>
        <script type="text/javascript" src="/static/jquery/jquery-ui-1.8.11.custom.min.js"></script>
        <script src="/static/bootstrap/js/bootstrap-transition.js"></script>
        <script src="/static/bootstrap/js/bootstrap-alert.js"></script>
        <script src="/static/bootstrap/js/bootstrap-modal.js"></script>
        <script src="/static/bootstrap/js/bootstrap-dropdown.js"></script>
        <script src="/static/bootstrap/js/bootstrap-scrollspy.js"></script>
        <script src="/static/bootstrap/js/bootstrap-tab.js"></script>
        <script src="/static/bootstrap/js/bootstrap-tooltip.js"></script>
        <script src="/static/bootstrap/js/bootstrap-popover.js"></script>
        <script src="/static/bootstrap/js/bootstrap-button.js"></script>
        <script src="/static/bootstrap/js/bootstrap-collapse.js"></script>
        <script src="/static/bootstrap/js/bootstrap-carousel.js"></script>
        <script src="/static/bootstrap/js/bootstrap-typeahead.js"></script>

        <script type="text/javascript">
            var urls = {};
            var Anywhere = {};
            Anywhere.urls = {};
        </script>
        <script type="text/javascript" src="/static/anywhere/scripts/ajax_utils.js"></script>

        <script type="text/javascript" src="/static/anywhere/scripts/feedback_dialog.js"></script>
        
        <script type="text/javascript">
            $(function() {
                $.extend(
                    urls,
                    {
                        feedback: '/feedback/submit/'
                    }
                );
                
                    Anywhere.FeedbackDialog.Initialise(urls, true);
                
            });
        </script>

        <script type="text/javascript">

            var _gaq = _gaq || [];
            _gaq.push(['_setAccount', 'UA-18014859-6']);
            _gaq.push(['_trackPageview']);

            (function() {
                var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
                ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
                var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
            })();

        </script>

        



    </body>
</html>
